from django.contrib import admin

from . import models


class ProductInline(admin.TabularInline):
    model = models.Product


@admin.register(models.Product)
class ProductAdmin(admin.ModelAdmin):

    list_display = ('name', 'description', 'price')

    class Meta:
        model = models.Product
        fields = '__all__'


@admin.register(models.Order)
class OrderAdmin(admin.ModelAdmin):

    list_display = ('date_of_placing_order', 'total_price_of_products')
    inlines = [ProductInline]

    class Meta:
        model = models.Order
        fields = '__all__'


@admin.register(models.Discount)
class DiscountAdmin(admin.ModelAdmin):

    list_display = ('percent_off',)

    class Meta:
        model = models.Discount
        fields = '__all__'


@admin.register(models.TaxRate)
class TaxRateAdmin(admin.ModelAdmin):

    list_display = ('name', 'precentage')

    class Meta:
        model = models.TaxRate
        fields = '__all__'
